package cn.school.course.service.impl;

import cn.school.course.dao.CourseSessionsDao;
import cn.school.course.entity.CourseSessions;
import cn.school.course.service.CourseSessionsService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Calendar;

/**
 * @className: 课程节次ServiceImpl
 * @author: fangjin.tao
 * @date: 2023/1/5
 **/
@Service
public class CourseSessionsServiceImpl extends ServiceImpl<CourseSessionsDao, CourseSessions> implements CourseSessionsService {
	@Override
	@Transactional
	public void saveOrUpdateBiz(CourseSessions[] courseSessions) {
		LambdaQueryWrapper<CourseSessions> lambdaQueryWrapper = new LambdaQueryWrapper<>();
		if (courseSessions != null && courseSessions.length != 0) {
			for (CourseSessions courseSession : courseSessions) {
				courseSession.setModifyTime(Calendar.getInstance().getTime());
				this.baseMapper.updateById(courseSession);
			}
		}
		this.baseMapper.selectList(lambdaQueryWrapper);
	}
}